/*
 * PACKAGE NAME: com.jodinfo.outmirror.api.offlanguagezhcn.service
 * FILE    NAME: OffLanguageZhCnDaoImpl.java
 * COPYRIGHT: Copyright(c) © 2016 heroj Company Ltd. All Rights Reserved
 */ 
package com.jodinfo.outmirror.service.impl;

import java.math.BigInteger;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jodinfo.outmirror.entity.OffLanguageZhCnEntity;
import com.jodinfo.outmirror.service.OffLanguageZhCnBizService;
import com.jodinfo.outmirror.service.OffLanguageZhCnDmlService;
import com.jodinfo.outmirror.service.OffLanguageZhCnQueryService;
import com.jodinfo.outmirror.util.DateUtils;
import com.jodinfo.outmirror.util.ResponseEntity;
import com.jodinfo.outmirror.util.SysConstant;

@Service(value="offLanguageZhCnBizService")
public class OffLanguageZhCnBizServiceImpl implements OffLanguageZhCnBizService {
    private static final Logger logger = LoggerFactory.getLogger(OffLanguageZhCnBizServiceImpl.class);
 	
 	@Resource(name="offLanguageZhCnDmlService")
	private OffLanguageZhCnDmlService offLanguageZhCnDmlService;
	@Resource(name="offLanguageZhCnQueryService")
	private OffLanguageZhCnQueryService offLanguageZhCnQueryService;
	
/** 
	 * 
	 * @author ZhangYuanYuan
	 * @date 2016年12月30日 上午9:15:36
	 * @see com.jodinfo.outmirror.implementation.offlanguagezhcn.OffLanguageZhCnBizService#addOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity)
	 * @param OffLanguageZhCnEntity offLanguageZhCnEntity
	 * @return int
	 */
	public ResponseEntity addOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity) {
			ResponseEntity rs = new ResponseEntity(SysConstant.SUCCESS, "操作成功");
			try{
			  	 int i =  offLanguageZhCnDmlService.addOffLanguageZhCn(offLanguageZhCnEntity);
				 rs.setMessage(i+"条记录操作成功");
			 }catch(Exception e){
				String errorMessage = e.getMessage();
				logger.error(errorMessage);
				rs.setStatus(SysConstant.FAIL).setMessage(errorMessage);
			}
		return rs;
	}
	/** 
	 * 
	 * @author ZhangYuanYuan
	 * @date 2016年12月30日 上午9:15:36
	 * @see com.jodinfo.outmirror.implementation.offlanguagezhcn.OffLanguageZhCnBizService#updateOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity)
	 * @param OffLanguageZhCnEntity offLanguageZhCnEntity
	 * @return ResponseEntity
	 */
	public ResponseEntity updateOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity) {
		 ResponseEntity rs = new ResponseEntity(SysConstant.SUCCESS,"更新成功");
			try{
				offLanguageZhCnEntity.setCreateTime(DateUtils.getCurrentTime());
				offLanguageZhCnEntity.setLastUpdateUsrName(DateUtils.getCurrentTime());
				offLanguageZhCnDmlService.updateOffLanguageZhCn(offLanguageZhCnEntity);
			 }catch(Exception e){
				String errorMessage = e.getMessage();
				logger.error(errorMessage);
				rs.setStatus(SysConstant.FAIL).setMessage(errorMessage);
			}
		return rs;
	}
	/** 
	 * 
	 * @author ZhangYuanYuan
	 * @date 2016年12月30日 上午9:15:36
	 * @see com.jodinfo.outmirror.implementation.offlanguagezhcn.OffLanguageZhCnBizService#queryAllOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity)
	 * @param OffLanguageZhCnEntity offLanguageZhCnEntity
	 * @return String
	 */
	public String queryAllOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity) {
		return JSON.toJSONString(offLanguageZhCnQueryService.queryAllOffLanguageZhCn(offLanguageZhCnEntity));
	} 
	/** 
	 * 
	 * @author ZhangYuanYuan
	 * @date 2016年12月30日 上午9:15:36
	 * @see com.jodinfo.outmirror.implementation.offlanguagezhcn.OffLanguageZhCnBizService#queryAllOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity)
	 * @param OffLanguageZhCnEntity offLanguageZhCnEntity
	 * @return PageResult
	 */
	public String queryListForPageOffLanguageZhCn(OffLanguageZhCnEntity offLanguageZhCnEntity) {
		int index = offLanguageZhCnEntity.getPageIndex();
		Page<OffLanguageZhCnEntity> page = PageHelper.startPage(++index, offLanguageZhCnEntity.getPageSize());
		offLanguageZhCnQueryService.queryAllOffLanguageZhCn(offLanguageZhCnEntity);
		PageInfo<OffLanguageZhCnEntity> info = new PageInfo<OffLanguageZhCnEntity>(page);
		return JSON.toJSONString(info.getList());
		//return new PageResult( offLanguageZhCnQueryService.queryListForPageOffLanguageZhCn(offLanguageZhCnEntity), offLanguageZhCnQueryService.queryCountOffLanguageZhCn(offLanguageZhCnEntity)).toString();
	} 
	/** 
	 * 
	 * @author ZhangYuanYuan
	 * @date 2016年12月30日 上午9:15:36
	 * @see com.jodinfo.outmirror.implementation.offlanguagezhcn.OffLanguageZhCnQueryService#queryById(OffLanguageZhCnEntity offLanguageZhCnEntity)
	 * @param BigInteger id
	 * @return
	 */
	public OffLanguageZhCnEntity queryById(BigInteger id) {
		return offLanguageZhCnQueryService.queryById(id);
	}
	

}

